package net.mingsoft.dashboard.util;

import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;

import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author gengfa
 * @date 22/03/05
 */
public class MsgCodeUtil {

    private MsgCodeUtil() {}

    public static String randomCode(int limit) {
        Random random = new Random(new DateTime().getMillis());
        List<Integer> list = Stream.generate(() -> random.nextInt(10)).limit(limit).collect(Collectors.toList());
        return StringUtils.join(list, "");
    }
}
